package com.learning.dubbo.service.token.api;

/**
 * ClassName: GreetingsServiceStub
 * Description:
 * Date: 2020/7/2 14:01 【需求编号】
 *
 * @author Sam Sho
 * @version V1.0.0
 */
public class GreetingsServiceStub implements GreetingsService {

    private final GreetingsService greetingsService;

    /**
     * 构造函数传入真正的远程代理对象
     */
    public GreetingsServiceStub(GreetingsService greetingsService) {
        this.greetingsService = greetingsService;
    }

    @Override
    public String sayHi(String name) {

        // 此代码在客户端执行, 你可以在客户端做ThreadLocal本地缓存，或预先验证参数是否合法，等等
        try {
            System.out.println("*************************");
            return greetingsService.sayHi(name);
        } catch (Exception e) {
            // 你可以容错，可以做任何AOP拦截事项
            return "容错数据";
        }
    }
}
